

<?php
class Home extends CI_Controller
{
	function index()
	{
		$this->load->model("type_model");
		//$typname="实现";
		//$arr = array('type'=>11,'typeName'=>$typname);
		//$this->typeModel->insert($arr);
		$type = $this->type_model->select_type_typeName_link();
		$typeArr = array('typeArr'=>$type);
		$this->load->view('home_view', $typeArr);
//		$this->load->view('header_view');
//		$this->load->view('guider_view',$typeArr);
//      	$this->load->view('home_view');
//      	$this->load->view('content', $data);
//      	$this->load->view('footer_view');
	}
	
	function search()
	{	
		$this->load->model("type_model");
		$type = $this->type_model->select_type_typeName_link();
		$typeArr = array('typeArr'=>$type);
		$this->load->view('search_view', $typeArr);
	}
	
	function get_projects_by_type($type,$sort,$state)
	{	
		if($sort==2){
			$sort='id';
		}
		else if($sort==3){
			$sort='(currentMoney/collectMoney) desc';
		}else if($sort==4){
			$sort='currentMoney desc';
		}else
			$sort='id desc';//默认最新

		if(1==$state){//即将结束
			$state=1;	
		}else if(2==$state){
			$state=2;	
		}else if(3==$state){
			$state=3;	
		}else 
			unset($state);
		
		$this->load->model("project_model");
		$arr = $this->project_model->select_by_type($type,$sort,$state);
		echo json_encode($arr);
	}
	
	function get_projects_by_time($type,$time)
	{
		$this->load->model("project_model");
		$arr = $this->project_model->select_by_type($type,$time);
		echo json_encode($arr);
	}
	
	function test()
	{
		$this->load->model("project_model");
		$arr = $this->project_model->select_by_id(20);
		echo json_encode($arr);
	}
}
?>